from piston.resource import Resource
from django.conf.urls.defaults import *
from handlers import *
from authentication import *

class CustomResource(Resource):
	callmap = { 'GET': 'read', 'POST': 'search',
                'PUT': 'update', 'DELETE': 'delete' }

auth = HttpBasicAuthenticationGroupMembership(realm="TrackEye API")
ad = { 'authentication': auth }
api_handler = CustomResource(APIHandler, **ad)

def api_url(pattern, view, view_kwargs={}, **kwargs):
    view_kwargs.setdefault('emitter_format', 'json')
    return url(pattern, view, view_kwargs, **kwargs)

urlpatterns = patterns('',
    # GET, POST, PUT
    api_url(r'^log/$', api_handler),
)
